package com.jiazhong.多态and转型.Test05;

public class PloyArray {
    public static void main(String[] args) {
        Person[] person=new Person[5];
        person[0]=new Person("jack",21);
        person[1]=new Person("marry",22);
        person[2]=new Person("smith",23);
        person[3]=new Person("table",24);
        person[4]=new Person("nike",25);
        for (int i=0;i<person.length;i++){
            System.out.println(person[i].Say());
            if (person[i]instanceof Student){
                Student student=(Student) person[i];
                student.study();
            }
            else if (person[i]instanceof Teacher){
                Teacher teacher=(Teacher) person[i];
                teacher.teach();
            }
            else if (person[i]instanceof Person){
                System.out.println("你的类型有误，请自己检查");
            }
            else{
                System.out.println("你的类型有误，请自己检查");
            }
        }
    }
}
